# -*- coding: utf-8 -*- 
# 作者:飞虎
# 开发时间:2022/5/29 21:52
from PyQt5.Qt import *


class Window(QWidget):
	def __init__(self):
		super().__init__()
		self.setWindowTitle('QTabWidget学习')
		self.resize(500, 500)
		self.setup_ui()

	def setup_ui(self):
		page_1 = QWidget()
		page_2 = QPlainTextEdit()
		tab_widget = QTabWidget(self)
		tab_widget.move(50, 50)
		tab_widget.resize(400, 400)

		lb_1 = QLabel('这是第一个标签页', page_1)
		lb_1.move(100, 100)

		tab_widget.addTab(page_1, 'Tab1')

		page_2.setPlainText("这是第二个标签页")
		tab_widget.insertTab(1,page_2,'Tab2')

		# 父控件关系
		print(page_1.parentWidget())
		print(page_2.parentWidget())
		print(tab_widget)
		print(page_2.parentWidget().parentWidget())

		# 标签位置
		# tab_widget.setTabPosition(QTabWidget.North)
		# tab_widget.setTabPosition(QTabWidget.South)
		# tab_widget.setTabPosition(QTabWidget.West)
		# tab_widget.setTabPosition(QTabWidget.East)

		# 标签形状
		# tab_widget.setTabShape(QTabWidget.Rounded)
		tab_widget.setTabShape(QTabWidget.Triangular)


if __name__ == '__main__':
	import sys

	app = QApplication(sys.argv)
	window = Window()
	window.show()
	sys.exit(app.exec_())
